﻿@model RTW.Models.TRole
@{
    ViewData["Title"] = "UserRoleEdit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section head{
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet" />
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" />
    <link href="/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
    <link href="/css/animate.min.css" rel="stylesheet" />
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" />
    <link href="/css/plugins/iCheck/custom.css" rel="stylesheet" />
    <link href="/css/style.min.css?v=4.1.0" rel="stylesheet" />
    <style type="text/css">
        .input-group-addon {
            width: 80px;
        }

        .input-group {
            margin-bottom: 15px;
            text-align: center;
            width: 100%;
        }

        .text-left label {
            font-weight: normal;
            margin-right: 8px;
            margin-left: 2px;
        }

        .checkbox label, .radio label {
            padding-left: 0px;
        }
    </style>

}
<form id="form1" asp-action="UserRoleEdit">
    <div id="dContent">
        <div class="input-group">
            <span class="input-group-addon">名称</span>
            @*<asp:TextBox ID="txtRName" runat="server" CssClass="form-control" dataType="null" Msg="名称不能为空!"></asp:TextBox>*@
            @Html.TextBoxFor(m => m.RName, new { @Class = "form-control", dataType = "null", Msg = "名称不能为空!" })
        </div>
        <div class="input-group">
            <span class="input-group-addon">阅卷权限</span>
            @*<asp:DropDownList ID="ddlYJQX" runat="server" CssClass="form-control">
                    <asp:ListItem Value="1" Text="个人"></asp:ListItem>
                    <asp:ListItem Value="2" Text="部门"></asp:ListItem>
                    <asp:ListItem Value="3" Text="全院"></asp:ListItem>
                </asp:DropDownList>*@
            @Html.DropDownListFor(m => m.Flag2, new SelectList(
                                                  new List<object>{
                                                       new { value = 1 , text = "个人" },
                                                       new { value = 2 , text = "部门" },
                                                       new { value = 3 , text = "全院" }
                                                    },
                                                  "value",
                                                  "text"
                                                ), new { @class = "form-control" })
        </div>
        <div class="input-group">
            <span class="input-group-addon">备注</span>
            @*<asp:TextBox ID="txtRemark" runat="server" CssClass="form-control" TextMode="MultiLine" Height="50"></asp:TextBox>*@
            @Html.TextAreaFor(m => m.Remark, new { @Class = "form-control", TextMode = "MultiLine", Height = "50" })
        </div>
        <div class="input-group">
            <span class="input-group-addon">档案水印</span>
            <div class="form-control text-left">
                <div class="checkbox i-checks" style="float: left; margin-right: 5px; width: 150px; text-align: left; margin-top: 5px;">
                    @Html.CheckBoxFor(m => m.WMValue)
                    <label style="padding-left: 0px;">
                        @*<asp:CheckBox ID="cboxWM" runat="server" Text="启用" />*@
                        启用
                    </label>
                </div>
            </div>
        </div>
        <div class="input-group">
            <span class="input-group-addon">状态</span>
            <div class="form-control text-left">
                <div class="checkbox i-checks" style="float: left; margin-right: 5px; width: 150px; text-align: left; margin-top: 5px;">
                    @Html.CheckBoxFor(m => m.StateValue)
                    <label style="padding-left: 0px;">
                        @*<asp:CheckBox ID="cboxState" runat="server" Text="停用" />*@
                        停用
                    </label>
                </div>
            </div>
        </div>
        <div class="input-group">
            <span class="input-group-addon">索引</span>
            @*<asp:TextBox ID="txtIndex" runat="server" CssClass="form-control" dataType="null,zzs" Msg="索引格式不正确!"></asp:TextBox>*@
            @Html.TextBoxFor(m => m.Flag1, new { @Class = "form-control", dataType = "null,zzs", Msg = "索引格式不正确!" })
        </div>
    </div>
    <div class="zui-footer">
        @*<asp:Button ID="btnSave" runat="server" CssClass="btn btn-primary btn-sm" Text="保存" OnClick="btnSave_Click" OnClientClick="return verfic('tip', '#dContent');" />*@
        <button id="btnSave" class="btn btn-primary btn-sm" type="submit">保存</button>
        <button class="btn btn-default btn-sm" type="button" onclick="closePage()">关闭</button>
    </div>
    @Html.HiddenFor(m => m.DMID)
    @Html.HiddenFor(m => m.ID)
    @Html.HiddenFor(m => m.AddTime)
</form>
@section scripts{
    <script src="/js/jquery.min.js?v=2.1.4"></script>
    <script src="/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="/js/plugins/jeditable/jquery.jeditable.js"></script>
    <script src="/js/plugins/dataTables/jquery.dataTables.js"></script>
    <script src="/js/plugins/dataTables/dataTables.bootstrap.js"></script>

    <script src="/js/My97DatePicker/WdatePicker.js"></script>
    <script src="/js/plugins/layer/layer.min.js"></script>
    <script src="/js/plugins/iCheck/icheck.min.js"></script>
    <script src="~/lib/jquery.form/jquery.form.min.js"></script>
    <script src="~/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="~/js/plugins/validate/additional-methods.min.js"></script>
    <script src="/js/verification.js"></script>

    <script type="text/javascript">


        //$(function () {
        //    $(".i-checks").iCheck({
        //        checkboxClass: "icheckbox_square-green",
        //        radioClass: "iradio_square-green"
        //    })
        //})

            //提交
            (function ($) {
                $.role = {
                    init: function () {
                        $(".i-checks").iCheck({
                            checkboxClass: "icheckbox_square-green",
                            radioClass: "iradio_square-green"
                        })
                    },
                    formSubmit: function () {
                        $("#form1").validate({
                            rules: {
                                RName: {
                                    required: true
                                },
                                Flag1: {
                                    required: true
                                }
                            },
                            errorPlacement: function (error, element) {
                                //错误消息不为空，提示Msg消息或默认消息
                                if (error[0].textContent != "") {
                                    if (error[0].textContent != undefined) {
                                        let msg = element.attr("Msg") ? element.attr("Msg") : error.textContent;
                                        showTip(msg, 2);
                                    }
                                }
                            },
                            onkeyup: false,
                            focusCleanup: true,
                            success: "valid",

                            submitHandler: function (form) {
                                //return verfic('tip', '#dContent');
                                //var fRankName = $("select[name='fRankId']").find("option:selected").text();
                                //var fState = $("input[name='fState']").is(':checked');
                                $(form).ajaxSubmit({
                                    type: "POST",
                                    cache: false,
                                    //data: { fRankName: fRankName, fState: fState },
                                    dataType: "json",
                                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                                        if (XMLHttpRequest.status != 200) {
                                            showTip(errorThrown, 2);
                                        }
                                    },
                                    success: function (result) {

                                        var state = result.success;
                                        var message = result.msg;
                                        if (state) {
                                            showTip(message, 1, 2);
                                        } else {
                                            showTip(message, 2);
                                        }

                                    }
                                });
                            }
                        });
                    }
                };

                $(function () {
                    $.role.init();
                    $.role.formSubmit();
                });
            })(jQuery);
    </script>


}
